package com.usc;

import com.usc.bean.Orders;
import com.usc.bean.Product;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import java.util.concurrent.Executor;
import java.util.Date;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class App1 {
    public static void main(String[] args) {
        ApplicationContext ac = new AnnotationConfigApplicationContext(AppConfig1.class);
        Orders orders = (Orders) ac.getBean("orders");
        System.out.println(orders);
        Product product = (Product) ac.getBean("p");
        System.out.println(product);
        Executor executor =(Executor) ac.getBean("threadPool");
        executor.execute(()->{
            while(true){try{
                Thread.sleep(1000);
            } catch (InterruptedException e ){
                throw new RuntimeException(e);
            }
            System.out.println(new Date());
        }
    });
}}
